package educationaladministrationsystem.CSM.Mapper.Service.Root;

import educationaladministrationsystem.CSM.Mapper.Service.ServiceInterface.RootInterface.RootProfessionalManagement;
import educationaladministrationsystem.Class.Faculties;
import educationaladministrationsystem.Class.MajorProgram;
import educationaladministrationsystem.CSM.Mapper.Root.RootProfessionalManagementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RootProfessionalManagementService implements RootProfessionalManagement {
    @Autowired
    private RootProfessionalManagementMapper rootProfessionalManagementMapper;

    @Override
    public List<Faculties> getAllFacultiesInformation() {
        return rootProfessionalManagementMapper.getAllFacultiesInformation();
    }

    @Override
    public String getFacultiesName(String id) {
        return rootProfessionalManagementMapper.getFacultiesName(id);
    }

    @Override
    public List<MajorProgram> getAllProfessionMajor(int page, int pageNumber) {
        return rootProfessionalManagementMapper.getAllProfessionMajor((page - 1) * pageNumber, pageNumber);
    }

    @Override
    public void addNewProfessionMajor(MajorProgram majorProgram) {
        System.out.println(majorProgram);
        rootProfessionalManagementMapper.addNewProfessionMajor(majorProgram);
    }

    @Override
    public int getAllPage(int pageNumber) {
        double allPage = rootProfessionalManagementMapper.getPage();
        return (int) Math.ceil(allPage / pageNumber);
    }

    @Override
    public MajorProgram getUpdateProfessionMajorInformation(int id) {
        return rootProfessionalManagementMapper.getUpdateProfessionMajorInformation(id);
    }

    @Override
    public void updateProfessionMajor(String id, String name, String facultiesId, String oldId) {
        System.out.println(id + " " + name + " " + facultiesId + " " + oldId);
        rootProfessionalManagementMapper.updateProfessionMajor(id, name, facultiesId, oldId);
    }

    @Override
    public void deleteProfessionMajor(String id) {
        rootProfessionalManagementMapper.deleteProfessionMajor(id);
    }
}
